/** Fades an object that implements the CCRGBAProtocol protocol. It modifies the opacity from the current value to a custom one.
 @warning This action doesn't support "reverse"
 */
class CCFadeTo extends CCActionInterval
{
var toOpacity_ :Float;
var fromOpacity_ :Float;

/** creates an action with duration and opactiy */
public static function actionWithDuration (duration:Float, opactiy:Float) :id
{
	return [[[ this alloc] initWithDuration: t opacity: o] autorelease];
}
/** initializes the action with duration and opacity */
public function initWithDuration (duration:Float, opacity:Float) :id
{
	if( (this=super.initWithDuration: t] ) )
		toOpacity_ = o;
	
	return this;
}

public function startWithTarget:(CCNode *)aTarget
{
	super.startWithTarget ( aTarget );
	fromOpacity_ = [(id<CCRGBAProtocol>)target_ opacity];
}

function update (t:Float) :Void
{
	[(id<CCRGBAProtocol>)target_ setOpacity:fromOpacity_ + ( toOpacity_ - fromOpacity_ ) * t];
}
}
